//----------------------------------------------------------------------------
// M A R I T I M E  R E S E A R C H  I N S T I T U T E  N E T H E R L A N D S
//----------------------------------------------------------------------------
// Copyright (C) 2012 - MARIN - All rights reserved - http://www.marin.nl
//----------------------------------------------------------------------------
// Program    : mermaid
// Module     : vbm
// File       : adjustpsi_kernels.h
// Author     : M.A. de Jong
//----------------------------------------------------------------------------

#ifndef ADJUSTPSI_KERNELS_H
#define ADJUSTPSI_KERNELS_H

#ifdef USEDOUBLE
#define ONE 1.0
#else
#define ONE 1.0f
#endif

namespace wavescomputer
{

template <class T>
__global__ void kernel_adjustpsi(T *psi,
                                 const T *psim1,
                                 const T *psim2,
                                 const T beta,
                                 const int ld,
                                 const int Nx1,
                                 const int Nx2)
{
    int u = bx * Bx + tx;
    int v = by * By + ty;
    int tid = v * ld + u;

    const T beta1 = beta + ONE;

    psi[tid] = beta1 * psim1[tid] - beta * psim2[tid];
}

} // namespace wavescomputer

#endif // ADJUSTPSI_KERNELS_H

